$(function () {
	var selfUrl=location.href;
	var paramData={'companyId':null,'branchAll':null};

    var companyInfoId = getUrlParam("companyId");
    paramData.companyId = companyInfoId

    var branchAll = getUrlParam("branchAll");
    paramData.branchAll = branchAll

    $("#employeeInfoGrid").Grid({
		url: '../org/employeeInfo/list',
		colModel: [
           {label: 'id', name: 'id', index: 'id', key: true, hidden: true},
           {label: '姓名', name: 'name', index: 'name', width: 80},
           {label: '手机号', name: 'phone', index: 'phone', width: 80},
           {label: '人员id', name: 'personId', index: 'personId', width: 80, hidden: true},
           {label: '职位', name: 'positionName', index: 'position', width: 80},
           {label: '部门', name: 'departName', index: 'position', width: 80},
           {label: '创建时间', name: 'createTime', index: 'create_time', width: 80}],
         postData: paramData
    });
	vm.getBranchAllList();
});

var vm = new Vue({
	el: '#employeeInfo',
	data: {
        showList: true,
        title: null,
        companyIdVal:'',
		orgEmployee: {},
		branchAll:[],
		q: {
		    name: '',phone:'',branchId:'',branchName:'',positionName:''
		}
	},
	methods: {
		query: function () {
			vm.reload();
		},
        getBranchAllList:function(){
            Ajax.request({
                url: "../org/branch/queryAll",
                async: true,
                successCallback: function (r) {
                    vm.branchAll = r.list;
                }
            });
        },
		reload: function (event) {
			vm.showList = true;
            var page = $("#employeeInfoGrid").jqGrid('getGridParam', 'page');
			$("#employeeInfoGrid").jqGrid('setGridParam', {
                postData: {'name': vm.q.name,'phone':vm.q.phone,'companyId':vm.companyIdVal,'branchId':vm.q.branchId,'positionName':vm.q.positionName},
                page: 1
            }).trigger("reloadGrid");
            // vm.handleReset('formValidate');
		},
        reloadSearch: function() {
            vm.q = {
                name: '',phone:'',positionName:''
            };
            vm.reload();
        }
	}
});